import { Suspense, lazy } from 'react';
import { CircleLoading } from '@/components/loading';
import DashboardLayout from '../../../layouts/dashboard';
import { Navigate, Outlet } from 'react-router-dom';


// 集成共享
const DataSourceIndex = lazy(() => import(`@/pages/dataSource`))
const DataSubjectIndex = lazy(() => import(`@/pages/dataSubject`))
const DataSubjectDetail = lazy(() => import(`@/pages/dataSubject/detail`))
const DataSubjectDesign = lazy(() => import(`@/pages/dataSubject/design`))
const DataCatalogIndex = lazy(() => import(`@/pages/dataCatalog`))
const DataCatalogDetail = lazy(() => import(`@/pages/dataCatalog/detail`))
const DataCatalogEdit = lazy(() => import(`@/pages/dataCatalog/edit`))
const DataCatalogTryout = lazy(() => import(`@/pages/dataCatalog/tryout`))
const ServiceCatalogIndex = lazy(() => import(`@/pages/serviceCatalog`))
const ServiceCatalogDetail = lazy(() => import(`@/pages/serviceCatalog/detail`))
const ServiceCatalogEdit = lazy(() => import(`@/pages/serviceCatalog/edit`))
const ServiceCatalogTryout = lazy(() => import(`@/pages/serviceCatalog/tryout`))
const ServiceCatalogAdd = lazy(() => import(`@/pages/serviceCatalog/add`))
const RedisIndex = lazy(() => import(`@/pages/redis`))
const KafkaIndex = lazy(() => import(`@/pages/kafka`))

const DmServiceIndex = lazy(() => import(`@/pages/dmService`))
const DmServiceEdit = lazy(() => import(`@/pages/dmService/edit`))
const DmServiceDetail = lazy(() => import(`@/pages/dmService/detail`))


function Wrapper() {
  return <Suspense fallback={<CircleLoading />}><Outlet /></Suspense>;
}

const management = {
  element: <DashboardLayout><Wrapper /></DashboardLayout>,
  children: [
    {
      path: 'dataSource',
      children: [{ index: true, element: <DataSourceIndex /> }],
    },
    {
      path: 'dataSubject',
      children: [
        { index: true, element: <DataSubjectIndex /> },
        {
          path: ':id',
          element: <DataSubjectDetail />,
        },
        {
          path: ':id/design',
          element: <DataSubjectDesign />,
        },
      ],
    },
    {
      path: 'dataCatalog',
      children: [
        { index: true, element: <DataCatalogIndex /> },
        {
          path: 'create',
          element: <DataCatalogEdit />,
        },
        {
          path: ':id',
          element: <DataCatalogDetail />,
        },
        {
          path: ':id/edit',
          element: <DataCatalogEdit />,
        },
        {
          path: ':id/tryout',
          element: <DataCatalogTryout />,
        },
      ],
    },
    {
      path: 'serviceCatalog',
      children: [
        { index: true, element: <ServiceCatalogIndex /> },
        {
          path: ':id',
          element: <ServiceCatalogDetail />,
        },
        {
          path: ':id/edit',
          element: <ServiceCatalogEdit />,
        },
        {
          path: ':id/tryout',
          element: <ServiceCatalogTryout />,
        },
        {
          path: 'add',
          element: <ServiceCatalogAdd />,
        },
      ],
    },
    {
      path: 'redis',
      children: [
        { index: true, element: <RedisIndex /> }
      ],
    },
    {
      path: 'kafka',
      children: [
        { index: true, element: <KafkaIndex /> }
      ],
    },
    {
      path: 'dmService',
      children: [
        { index: true, element: <DmServiceIndex /> },
        {
          path: 'add',
          element: <DmServiceEdit />,
        },
        {
          path: ':id/edit',
          element: <DmServiceEdit />,
        },
        {
          path: ':id',
          element: <DmServiceDetail />,
        },
      ],
    },
  ],
};

export default management;
